/**
@Description  请填写文件描述（需要改）
@author: freedom
@date: 2021/5/25
@note:
**/
package initialize

import (
	"gin-vue-admin/global"
	"github.com/olivere/elastic/v7"
	"log"
	"os"
	"time"
)

//初始化ES 配置
func ES() {
	client, err := elastic.NewClient(
		elastic.SetURL(global.GVA_CONFIG.ES.Urs...),
		elastic.SetSniff(global.GVA_CONFIG.ES.Sniff),
		elastic.SetHealthcheckInterval(5*time.Second),
		elastic.SetGzip(false),
		elastic.SetErrorLog(log.New(os.Stderr, "ES_ERROR ", log.LstdFlags)),
		elastic.SetInfoLog(log.New(os.Stdout, "ES_INFO ", log.LstdFlags)),
		elastic.SetTraceLog(log.New(os.Stdout, "ES_TRACE ", log.LstdFlags)))
	if err != nil {
		global.GVA_LOG.Error("create es client failed," + err.Error())
	}
	global.GVA_ES = client

}
